<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<button id="abc">点击</button>
</body>
</html>
<script type="text/javascript">
    // window.οnlοad=function(){
    // 	const synth = window.speechSynthesis
    // let msg = new SpeechSynthesisUtterance("你好");
    // console.log(msg)
    // //msg.rate = 4 播放语速
    // //msg.pitch = 10 音调高低
    // //msg.text = "播放文本"
    // //msg.volume = 0.5 播放音量
    // synth.speak(msg);
    // }
    const synth = window.speechSynthesis
    const msg = new SpeechSynthesisUtterance()
    msg.text = '车辆浙A91AD出现滞留'
    msg.lang = 'zh-CN'
    function handleSpeak(e) {
        synth.speak(msg)
    }
    function throttle(fn,delay) {
        let last = 0
        return function() {
            const now = new Date()
            if(now - last > delay) {
                fn.apply(this,arguments)
                last = now
            }
        }
    }

    console.log(msg);

    document.getElementById('abc').onclick=throttle(handleSpeak,1000);
</script>